﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PES_TurnierManager
{
    /// <summary>
    /// Interaktionslogik für TextBoxDialog.xaml
    /// </summary>
    public partial class TextBoxDialog : Window
    {
        bool mDialogResult;

        public TextBoxDialog()
        {
            InitializeComponent();
            mDialogResult = false;
        }

        public TextBoxDialog(string caption, string description)
        {
            InitializeComponent();
            mDialogResult = false;
            this.Title = caption;
            mDescMessage.Text = description;
        }

        private void mButton_Click(object sender, RoutedEventArgs e)
        {
            //Cast to Button
            Button button = (Button)sender;

            //Check which button was pressed and set teh result
            if(button.Name.Equals("mOKButton"))
                mDialogResult = true;
            else
                mDialogResult = false;

            //Close the Window after clicking on "OK" or "Cancel"
            Close();
        }

        /// <summary>
        /// Gets the result of the dialog. Call this after the Dialog was closed.
        /// </summary>
        /// <returns>The Dialog result</returns>
        public bool getDialogResult()
        {
            return mDialogResult;
        }

        public bool isLegBoxChecked()
        {
            return (bool)mTwoLegCheckBox.IsChecked;
        }

        /// <summary>
        /// Gets the Content of the Textbox
        /// </summary>
        /// <returns>The text inside the box</returns>
        public string getTextBoxContent()
        {
            return mTextBox.Text;
        }

        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (mTextBox.Text != "")
                    mDialogResult = true;

                //Close Window when Enter is pressed and the box is not empty
                Close();
            }           
        }
    }
}
